<!-- HTML header for doxygen 1.8.8-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <!-- For Mobile Devices -->
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
        <meta name="generator" content="Doxygen 1.8.17"/>
        <script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
        <title>QuEST: Calculations</title>
        <!--<link href="tabs.css" rel="stylesheet" type="text/css"/>-->
        <script type="text/javascript" src="dynsections.js"></script>
        <link href="doxygen.css" rel="stylesheet" type="text/css" />
        <link href="style.css" rel="stylesheet" type="text/css"/>
        <link href='https://fonts.googleapis.com/css?family=Roboto+Slab' rel='stylesheet' type='text/css'>
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
        <link href="jquery.smartmenus.bootstrap.css" rel="stylesheet">
        <script type="text/javascript" src="jquery.smartmenus.js"></script>
        <!-- SmartMenus jQuery Bootstrap Addon -->
        <script type="text/javascript" src="jquery.smartmenus.bootstrap.js"></script>
        <!-- SmartMenus jQuery plugin -->
    </head>
    <body>
        <nav class="navbar navbar-default" role="navigation">
            <div class="container">
                <div class="navbar-header">
                    <a class="navbar-brand"><img alt="Logo" src="logo.png"/></a>
                    <a class="navbar-brand"><b>QuEST</b> v3.2.0<br>The Quantum Exact Simulation Toolkit</a>
                </div>
            </div>
        </nav>
        <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
            <div class="content" id="content">
                <div class="container">
                    <div class="row">
                        <div class="col-sm-12 panel " style="padding-bottom: 15px;">
                            <div style="margin-bottom: 15px;">
<!-- end header part -->
<!-- Generated by Doxygen 1.8.17 -->
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',false,false,'search.php','Search');
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">Calculations</div>  </div>
</div><!--header-->
<div class="contents">

<p>Calculations and property-getters which do not modify the studied quantum state.  
<a href="#details">More...</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ga658b3a5cab5e73a17a7fd76a83583a22"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__calc.html#ga658b3a5cab5e73a17a7fd76a83583a22">calcDensityInnerProduct</a> (<a class="el" href="structQureg.html">Qureg</a> rho1, <a class="el" href="structQureg.html">Qureg</a> rho2)</td></tr>
<tr class="memdesc:ga658b3a5cab5e73a17a7fd76a83583a22"><td class="mdescLeft">&#160;</td><td class="mdescRight">Computes the Hilbert-Schmidt scalar product (which is equivalent to the Frobenius inner product of matrices) of two density matrices <code>rho1</code> and <code>rho2</code> of equivalent size.  <a href="group__calc.html#ga658b3a5cab5e73a17a7fd76a83583a22">More...</a><br /></td></tr>
<tr class="separator:ga658b3a5cab5e73a17a7fd76a83583a22"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga82f17e96a4cb7612fb9c6ef856df3810"><td class="memItemLeft" align="right" valign="top"><a class="el" href="structComplex.html">Complex</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__calc.html#ga82f17e96a4cb7612fb9c6ef856df3810">calcExpecDiagonalOp</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, <a class="el" href="structDiagonalOp.html">DiagonalOp</a> op)</td></tr>
<tr class="memdesc:ga82f17e96a4cb7612fb9c6ef856df3810"><td class="mdescLeft">&#160;</td><td class="mdescRight">Computes the expected value of the diagonal operator <code>op</code> for state <code>qureg</code>.  <a href="group__calc.html#ga82f17e96a4cb7612fb9c6ef856df3810">More...</a><br /></td></tr>
<tr class="separator:ga82f17e96a4cb7612fb9c6ef856df3810"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga5544d2833a69941b8820797b79daf79f"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__calc.html#ga5544d2833a69941b8820797b79daf79f">calcExpecPauliHamil</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, <a class="el" href="structPauliHamil.html">PauliHamil</a> hamil, <a class="el" href="structQureg.html">Qureg</a> workspace)</td></tr>
<tr class="memdesc:ga5544d2833a69941b8820797b79daf79f"><td class="mdescLeft">&#160;</td><td class="mdescRight">Computes the expected value of <code>qureg</code> under Hermitian operator <code>hamil</code>.  <a href="group__calc.html#ga5544d2833a69941b8820797b79daf79f">More...</a><br /></td></tr>
<tr class="separator:ga5544d2833a69941b8820797b79daf79f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga15cfad3f3d26339128e3be32ae7deacd"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__calc.html#ga15cfad3f3d26339128e3be32ae7deacd">calcExpecPauliProd</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int *targetQubits, enum <a class="el" href="group__type.html#ga1c703cf89629e4e9c7023cd402d67028">pauliOpType</a> *pauliCodes, int numTargets, <a class="el" href="structQureg.html">Qureg</a> workspace)</td></tr>
<tr class="memdesc:ga15cfad3f3d26339128e3be32ae7deacd"><td class="mdescLeft">&#160;</td><td class="mdescRight">Computes the expected value of a product of Pauli operators.  <a href="group__calc.html#ga15cfad3f3d26339128e3be32ae7deacd">More...</a><br /></td></tr>
<tr class="separator:ga15cfad3f3d26339128e3be32ae7deacd"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga50ee589fd5ceab52fdd70d0082352b41"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__calc.html#ga50ee589fd5ceab52fdd70d0082352b41">calcExpecPauliSum</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, enum <a class="el" href="group__type.html#ga1c703cf89629e4e9c7023cd402d67028">pauliOpType</a> *allPauliCodes, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *termCoeffs, int numSumTerms, <a class="el" href="structQureg.html">Qureg</a> workspace)</td></tr>
<tr class="memdesc:ga50ee589fd5ceab52fdd70d0082352b41"><td class="mdescLeft">&#160;</td><td class="mdescRight">Computes the expected value of a sum of products of Pauli operators.  <a href="group__calc.html#ga50ee589fd5ceab52fdd70d0082352b41">More...</a><br /></td></tr>
<tr class="separator:ga50ee589fd5ceab52fdd70d0082352b41"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaa266ed6c8ae5d0d0f49e1ac50819cffc"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__calc.html#gaa266ed6c8ae5d0d0f49e1ac50819cffc">calcFidelity</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, <a class="el" href="structQureg.html">Qureg</a> pureState)</td></tr>
<tr class="memdesc:gaa266ed6c8ae5d0d0f49e1ac50819cffc"><td class="mdescLeft">&#160;</td><td class="mdescRight">Calculates the fidelity of <code>qureg</code> (a statevector or density matrix) against a reference pure state (necessarily a statevector).  <a href="group__calc.html#gaa266ed6c8ae5d0d0f49e1ac50819cffc">More...</a><br /></td></tr>
<tr class="separator:gaa266ed6c8ae5d0d0f49e1ac50819cffc"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga87ddbe5c8281543541ccd99e0dafd387"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__calc.html#ga87ddbe5c8281543541ccd99e0dafd387">calcHilbertSchmidtDistance</a> (<a class="el" href="structQureg.html">Qureg</a> a, <a class="el" href="structQureg.html">Qureg</a> b)</td></tr>
<tr class="memdesc:ga87ddbe5c8281543541ccd99e0dafd387"><td class="mdescLeft">&#160;</td><td class="mdescRight">Computes the Hilbert Schmidt distance between two density matrices <code>a</code> and <code>b</code>, defined as the Frobenius norm of the difference between them.  <a href="group__calc.html#ga87ddbe5c8281543541ccd99e0dafd387">More...</a><br /></td></tr>
<tr class="separator:ga87ddbe5c8281543541ccd99e0dafd387"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga374ad70804998394ae41ebfe106258a6"><td class="memItemLeft" align="right" valign="top"><a class="el" href="structComplex.html">Complex</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__calc.html#ga374ad70804998394ae41ebfe106258a6">calcInnerProduct</a> (<a class="el" href="structQureg.html">Qureg</a> bra, <a class="el" href="structQureg.html">Qureg</a> ket)</td></tr>
<tr class="memdesc:ga374ad70804998394ae41ebfe106258a6"><td class="mdescLeft">&#160;</td><td class="mdescRight">Computes the inner product <img class="formulaInl" alt="$ \langle \text{bra} | \text{ket} \rangle $" src="form_84.png"/> of two equal-size state vectors, given by.  <a href="group__calc.html#ga374ad70804998394ae41ebfe106258a6">More...</a><br /></td></tr>
<tr class="separator:ga374ad70804998394ae41ebfe106258a6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga2a7946e6fa4f44c9ae0c6c9f683229ad"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__calc.html#ga2a7946e6fa4f44c9ae0c6c9f683229ad">calcProbOfOutcome</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int measureQubit, int outcome)</td></tr>
<tr class="memdesc:ga2a7946e6fa4f44c9ae0c6c9f683229ad"><td class="mdescLeft">&#160;</td><td class="mdescRight">Gives the probability of a specified qubit being measured in the given outcome (0 or 1).  <a href="group__calc.html#ga2a7946e6fa4f44c9ae0c6c9f683229ad">More...</a><br /></td></tr>
<tr class="separator:ga2a7946e6fa4f44c9ae0c6c9f683229ad"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga683779343fb2c6055f6b1d01079c2ede"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__calc.html#ga683779343fb2c6055f6b1d01079c2ede">calcPurity</a> (<a class="el" href="structQureg.html">Qureg</a> qureg)</td></tr>
<tr class="memdesc:ga683779343fb2c6055f6b1d01079c2ede"><td class="mdescLeft">&#160;</td><td class="mdescRight">Calculates the purity of a density matrix, by the trace of the density matrix squared.  <a href="group__calc.html#ga683779343fb2c6055f6b1d01079c2ede">More...</a><br /></td></tr>
<tr class="separator:ga683779343fb2c6055f6b1d01079c2ede"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gab082910d33473ec29e1d5852943de468"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__calc.html#gab082910d33473ec29e1d5852943de468">calcTotalProb</a> (<a class="el" href="structQureg.html">Qureg</a> qureg)</td></tr>
<tr class="memdesc:gab082910d33473ec29e1d5852943de468"><td class="mdescLeft">&#160;</td><td class="mdescRight">A debugging function which calculates the probability of the qubits in <code>qureg</code> being in any state, which should always be 1 for correctly normalised states (hence returning a real number).  <a href="group__calc.html#gab082910d33473ec29e1d5852943de468">More...</a><br /></td></tr>
<tr class="separator:gab082910d33473ec29e1d5852943de468"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga30d6f8b7c766c9c9914b2c61a2fc0def"><td class="memItemLeft" align="right" valign="top"><a class="el" href="structComplex.html">Complex</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__calc.html#ga30d6f8b7c766c9c9914b2c61a2fc0def">getAmp</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, long long int index)</td></tr>
<tr class="memdesc:ga30d6f8b7c766c9c9914b2c61a2fc0def"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get the complex amplitude at a given index in the state vector.  <a href="group__calc.html#ga30d6f8b7c766c9c9914b2c61a2fc0def">More...</a><br /></td></tr>
<tr class="separator:ga30d6f8b7c766c9c9914b2c61a2fc0def"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gadca286c4ad5cde6124d4e80a7ab95a68"><td class="memItemLeft" align="right" valign="top"><a class="el" href="structComplex.html">Complex</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__calc.html#gadca286c4ad5cde6124d4e80a7ab95a68">getDensityAmp</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, long long int row, long long int col)</td></tr>
<tr class="memdesc:gadca286c4ad5cde6124d4e80a7ab95a68"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get an amplitude from a density matrix at a given row and column.  <a href="group__calc.html#gadca286c4ad5cde6124d4e80a7ab95a68">More...</a><br /></td></tr>
<tr class="separator:gadca286c4ad5cde6124d4e80a7ab95a68"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gad575782de461d9ab0975b38cc7850f1a"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__calc.html#gad575782de461d9ab0975b38cc7850f1a">getImagAmp</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, long long int index)</td></tr>
<tr class="memdesc:gad575782de461d9ab0975b38cc7850f1a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get the imaginary component of the complex probability amplitude at an index in the state vector.  <a href="group__calc.html#gad575782de461d9ab0975b38cc7850f1a">More...</a><br /></td></tr>
<tr class="separator:gad575782de461d9ab0975b38cc7850f1a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga8cbe422d4981bf06847d229a4c6aa3df"><td class="memItemLeft" align="right" valign="top">long long int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__calc.html#ga8cbe422d4981bf06847d229a4c6aa3df">getNumAmps</a> (<a class="el" href="structQureg.html">Qureg</a> qureg)</td></tr>
<tr class="memdesc:ga8cbe422d4981bf06847d229a4c6aa3df"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get the number of probability amplitudes in a qureg object, given by 2^numQubits.  <a href="group__calc.html#ga8cbe422d4981bf06847d229a4c6aa3df">More...</a><br /></td></tr>
<tr class="separator:ga8cbe422d4981bf06847d229a4c6aa3df"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga73036c778d800703585ab3d8796a915f"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__calc.html#ga73036c778d800703585ab3d8796a915f">getNumQubits</a> (<a class="el" href="structQureg.html">Qureg</a> qureg)</td></tr>
<tr class="memdesc:ga73036c778d800703585ab3d8796a915f"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get the number of qubits in a qureg object.  <a href="group__calc.html#ga73036c778d800703585ab3d8796a915f">More...</a><br /></td></tr>
<tr class="separator:ga73036c778d800703585ab3d8796a915f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga4a14d22379d399760b0cfc5c8053589b"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__calc.html#ga4a14d22379d399760b0cfc5c8053589b">getProbAmp</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, long long int index)</td></tr>
<tr class="memdesc:ga4a14d22379d399760b0cfc5c8053589b"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get the probability of a state-vector at an index in the full state vector.  <a href="group__calc.html#ga4a14d22379d399760b0cfc5c8053589b">More...</a><br /></td></tr>
<tr class="separator:ga4a14d22379d399760b0cfc5c8053589b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga1416145280c62c5dd5ec9bed89b4cd05"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__calc.html#ga1416145280c62c5dd5ec9bed89b4cd05">getRealAmp</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, long long int index)</td></tr>
<tr class="memdesc:ga1416145280c62c5dd5ec9bed89b4cd05"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get the real component of the complex probability amplitude at an index in the state vector.  <a href="group__calc.html#ga1416145280c62c5dd5ec9bed89b4cd05">More...</a><br /></td></tr>
<tr class="separator:ga1416145280c62c5dd5ec9bed89b4cd05"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<p>Calculations and property-getters which do not modify the studied quantum state. </p>
<h2 class="groupheader">Function Documentation</h2>
<a id="ga658b3a5cab5e73a17a7fd76a83583a22"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga658b3a5cab5e73a17a7fd76a83583a22">&#9670;&nbsp;</a></span>calcDensityInnerProduct()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> calcDensityInnerProduct </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>rho1</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>rho2</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Computes the Hilbert-Schmidt scalar product (which is equivalent to the Frobenius inner product of matrices) of two density matrices <code>rho1</code> and <code>rho2</code> of equivalent size. </p>
<p>That is, we define the Hilbert-Schmidt scalar product </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ ((\rho_1, \rho_2))_{HS} := \text{Tr}[ \rho_1^\dagger \rho_2 ], \]" src="form_86.png"/>
</p>
<p> which is equivalent to the sum of products of matrix elemets, i.e., </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ ((\rho_1, \rho_2))_{HS} = \sum\limits_i \sum\limits_j (\rho_1)_{ij}^* (\rho_2)_{ij} \]" src="form_87.png"/>
</p>
<p> Assuming that both density matrices are Hermitian, the resulting scalar product is real and invariant under reordering its arguments as </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ ((\rho_1, \rho_2))_{HS} = ((\rho_2, \rho_1))_{HS} = \text{Tr}[\rho_1 \rho_2] \]" src="form_88.png"/>
</p>
<p> If both <code>rho1</code> and <code>rho2</code> are density matrices of pure states <code>bra</code> and <code>ket</code>, then the equality holds </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ ((\rho_1, \rho_2))_{HS} = |\langle \text{bra} | \text{ket} \rangle|^2. \]" src="form_89.png"/>
</p>
<p> If either or both of <code>rho1</code> and <code>rho2</code> are non Hermitian (i.e. invalid density matrices), then this function returns the real component of the scalar product, and discards the imaginary component. That is, it returns </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ \text{Re}\{ \text{Tr}[ \rho_1^\dagger \rho_2 ] \} = \text{Re}\{ \text{Tr}[ \rho_2^\dagger \rho_1 ] \}. \]" src="form_90.png"/>
</p>
<p> This is still sometimes useful, e.g. in calculating the inner product with an anti-commutator, e.g. (for Hermitian <img class="formulaInl" alt="$ \sigma $" src="form_91.png"/>, <img class="formulaInl" alt="$ \rho $" src="form_39.png"/>, <img class="formulaInl" alt="$ H $" src="form_92.png"/>) </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ ((\sigma, H \rho + \rho H))_{HS} = 2 \; \text{Re} \{ ((\sigma, H \rho))_{HS} \} \]" src="form_93.png"/>
</p>
<p> where <img class="formulaInl" alt="$ H \rho $" src="form_94.png"/> could be a weighted sum of Pauli products applied to <img class="formulaInl" alt="$ \rho $" src="form_39.png"/> through <a class="el" href="group__operator.html#ga6fc26cf857db070e12959e59ecfed8a6" title="Modifies outQureg to be the result of applying the weighted sum of Pauli products (a Hermitian but no...">applyPauliSum()</a>.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">rho1</td><td>qureg as a density matrix (to have its values conjugate transposed) </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">rho2</td><td>qureg as a density matrix </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>the real Hilbert-Schmidt scalar product of density matrices <code>rho1</code> and <code>rho2</code> (assuming Hermiticity) </dd></dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname">invalidQuESTInputError</td><td>if <code>rho1</code> and <code>rho2</code> are not density matrices or have mismatching dimensions. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Balint Koczor (CPU) </dd>
<dd>
Tyson Jones (GPU) </dd></dl>

<p class="definition">Definition at line <a class="el" href="QuEST_8c_source.html#l00918">918</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00918"></a><span class="lineno">  918</span>&#160;                                                      {</div>
<div class="line"><a name="l00919"></a><span class="lineno">  919</span>&#160;    <a class="code" href="QuEST__validation_8c.html#af22919f5190ca1b3b6b52b8f2fb8213b">validateDensityMatrQureg</a>(rho1, __func__);</div>
<div class="line"><a name="l00920"></a><span class="lineno">  920</span>&#160;    <a class="code" href="QuEST__validation_8c.html#af22919f5190ca1b3b6b52b8f2fb8213b">validateDensityMatrQureg</a>(rho2, __func__);</div>
<div class="line"><a name="l00921"></a><span class="lineno">  921</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a87d22240ccfd81827a2a34b8d569d347">validateMatchingQuregDims</a>(rho1, rho2, __func__);</div>
<div class="line"><a name="l00922"></a><span class="lineno">  922</span>&#160;    </div>
<div class="line"><a name="l00923"></a><span class="lineno">  923</span>&#160;    <span class="keywordflow">return</span> <a class="code" href="QuEST__internal_8h.html#a6ff3dc624b5fafe8edae4fe327c255a0">densmatr_calcInnerProduct</a>(rho1, rho2);</div>
<div class="line"><a name="l00924"></a><span class="lineno">  924</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00441">densmatr_calcInnerProduct()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00483">validateDensityMatrQureg()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00495">validateMatchingQuregDims()</a>.</p>

<p class="reference">Referenced by <a class="el" href="test__calculations_8cpp_source.html#l00015">TEST_CASE()</a>.</p>

</div>
</div>
<a id="ga82f17e96a4cb7612fb9c6ef856df3810"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga82f17e96a4cb7612fb9c6ef856df3810">&#9670;&nbsp;</a></span>calcExpecDiagonalOp()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="structComplex.html">Complex</a> calcExpecDiagonalOp </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structDiagonalOp.html">DiagonalOp</a>&#160;</td>
          <td class="paramname"><em>op</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Computes the expected value of the diagonal operator <code>op</code> for state <code>qureg</code>. </p>
<p>Since <code>op</code> is not necessarily Hermitian, the expected value may be a complex number.</p>
<p>Let <img class="formulaInl" alt="$ D $" src="form_182.png"/> be the diagonal operator <code>op</code>, with diagonal elements <img class="formulaInl" alt="$ d_i $" src="form_183.png"/>. Then if <code>qureg</code> is a state-vector <img class="formulaInl" alt="$|\psi\rangle $" src="form_184.png"/>, this function computes </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ \langle \psi | D | \psi \rangle = \sum_i |\psi_i|^2 \, d_i \]" src="form_187.png"/>
</p>
<p> If <code>qureg</code> is a density matrix <img class="formulaInl" alt="$ \rho $" src="form_39.png"/>, this function computes </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ \text{Trace}( D \rho ) = \sum_i \rho_{ii} \, d_i \]" src="form_188.png"/>
</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">qureg</td><td>a state-vector or density matrix </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">op</td><td>the diagonal operator to compute the expected value of </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>the expected vaulue of the operator </dd></dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname">invalidQuESTInputError</td><td>if <code>op</code> was not created, or if <code>op</code> acts on a different number of qubits than <code>qureg</code> represents. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="QuEST_8c_source.html#l00979">979</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00979"></a><span class="lineno">  979</span>&#160;                                                        {</div>
<div class="line"><a name="l00980"></a><span class="lineno">  980</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a8a656a83bf0b44447188d06c2f8114cb">validateDiagonalOp</a>(qureg, op, __func__);</div>
<div class="line"><a name="l00981"></a><span class="lineno">  981</span>&#160;    </div>
<div class="line"><a name="l00982"></a><span class="lineno">  982</span>&#160;    <span class="keywordflow">if</span> (qureg.<a class="code" href="structQureg.html#acf78445e9435d09f44f0cc832c6aee79">isDensityMatrix</a>)</div>
<div class="line"><a name="l00983"></a><span class="lineno">  983</span>&#160;        <span class="keywordflow">return</span> <a class="code" href="QuEST__internal_8h.html#a70e3b0a2297c186d5c779af31459b4ca">densmatr_calcExpecDiagonalOp</a>(qureg, op);</div>
<div class="line"><a name="l00984"></a><span class="lineno">  984</span>&#160;    <span class="keywordflow">else</span></div>
<div class="line"><a name="l00985"></a><span class="lineno">  985</span>&#160;        <span class="keywordflow">return</span> <a class="code" href="QuEST__internal_8h.html#a0fb948ddab4ca210e523aa3c52639df4">statevec_calcExpecDiagonalOp</a>(qureg, op);</div>
<div class="line"><a name="l00986"></a><span class="lineno">  986</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01541">densmatr_calcExpecDiagonalOp()</a>, <a class="el" href="QuEST_8h_source.html#l00206">Qureg::isDensityMatrix</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01523">statevec_calcExpecDiagonalOp()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00677">validateDiagonalOp()</a>.</p>

<p class="reference">Referenced by <a class="el" href="test__calculations_8cpp_source.html#l00111">TEST_CASE()</a>.</p>

</div>
</div>
<a id="ga5544d2833a69941b8820797b79daf79f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga5544d2833a69941b8820797b79daf79f">&#9670;&nbsp;</a></span>calcExpecPauliHamil()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> calcExpecPauliHamil </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structPauliHamil.html">PauliHamil</a>&#160;</td>
          <td class="paramname"><em>hamil</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>workspace</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Computes the expected value of <code>qureg</code> under Hermitian operator <code>hamil</code>. </p>
<p>Represent <code>hamil</code> as <img class="formulaInl" alt="$ H = \sum_i c_i \otimes_j^{N} \hat{\sigma}_{i,j} $" src="form_135.png"/> (where <img class="formulaInl" alt="$ c_i \in $" src="form_136.png"/> <code>hamil.termCoeffs</code> and <img class="formulaInl" alt="$ N = $" src="form_137.png"/> <code>hamil.numQubits</code>). This function computes <img class="formulaInl" alt="$ \langle \psi | H | \psi \rangle $" src="form_138.png"/> if <code>qureg</code> = <img class="formulaInl" alt="$ \psi $" src="form_37.png"/> is a statevector, and computes <img class="formulaInl" alt="$ \text{Trace}(H \rho) =\text{Trace}(\rho H) $" src="form_139.png"/> if <code>qureg</code> = <img class="formulaInl" alt="$ \rho $" src="form_39.png"/> is a density matrix.</p>
<p>This function is merely an encapsulation of <a class="el" href="group__calc.html#ga50ee589fd5ceab52fdd70d0082352b41" title="Computes the expected value of a sum of products of Pauli operators.">calcExpecPauliSum()</a> - refer to the doc there for an elaboration.</p>
<p><code>workspace</code> must be a register with the same type (statevector vs density matrix) and dimensions (number of represented qubits) as <code>qureg</code> and <code>hamil</code>, and is used as working space. When this function returns, <code>qureg</code> will be unchanged and <code>workspace</code> will be set to <code>qureg</code> pre-multiplied with the final Pauli product in <code>hamil</code>. NOTE that if <code>qureg</code> is a density matrix, <code>workspace</code> will become <img class="formulaInl" alt="$ \hat{\sigma} \rho $" src="form_141.png"/> which is itself not a density matrix (it is distinct from <img class="formulaInl" alt="$ \hat{\sigma} \rho \hat{\sigma}^\dagger $" src="form_181.png"/>).</p>
<p>This function works by cloning the <code>qureg</code> state into <code>workspace</code>, applying each of the specified Pauli products in <code>hamil</code> to <code>workspace</code> (one Pauli operation at a time), then computing its inner product with <code>qureg</code> (for statevectors) or its trace (for density matrices) multiplied with the corresponding coefficient, and summing these contributions. It therefore should scale linearly in time with the total number of non-identity specified Pauli operators.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">qureg</td><td>the register of which to find the expected value, which is unchanged by this function </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">hamil</td><td>a <code><a class="el" href="structPauliHamil.html" title="Represents a weighted sum of pauli products.">PauliHamil</a></code> created with <a class="el" href="group__type.html#ga35b28710877c462927366fa602e591cb" title="Create a PauliHamil instance, which is a Hamiltonian expressed as a real-weighted sum of products of ...">createPauliHamil()</a> or <a class="el" href="group__type.html#gaa77376c5e3518186eb085f37826d6008" title="Create a PauliHamil instance, a real-weighted sum of products of Pauli operators, populated with the ...">createPauliHamilFromFile()</a> </td></tr>
    <tr><td class="paramdir">[in,out]</td><td class="paramname">workspace</td><td>a working-space qureg with the same dimensions as <code>qureg</code>, which is modified to be the result of multiplying the state with the final specified Pauli product </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname">invalidQuESTInputError</td><td>if any code in <code>hamil.pauliCodes</code> is not a valid Pauli code, or if <code>hamil.numSumTerms</code> &lt;= 0, or if <code>workspace</code> is not of the same type and dimensions as <code>qureg</code> and <code>hamil</code> </td></tr>
  </table>
  </dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="QuEST_8c_source.html#l00970">970</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00970"></a><span class="lineno">  970</span>&#160;                                                                          {</div>
<div class="line"><a name="l00971"></a><span class="lineno">  971</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a031812e1cf2c98d72d795cea7bbe73a5">validateMatchingQuregTypes</a>(qureg, workspace, __func__);</div>
<div class="line"><a name="l00972"></a><span class="lineno">  972</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a87d22240ccfd81827a2a34b8d569d347">validateMatchingQuregDims</a>(qureg, workspace, __func__);</div>
<div class="line"><a name="l00973"></a><span class="lineno">  973</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a066b0c4d0b02a0f3b9be7e5c68d9de6a">validatePauliHamil</a>(hamil, __func__);</div>
<div class="line"><a name="l00974"></a><span class="lineno">  974</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a2b88b068a8242ee28da42c7324cdd078">validateMatchingQuregPauliHamilDims</a>(qureg, hamil, __func__);</div>
<div class="line"><a name="l00975"></a><span class="lineno">  975</span>&#160;    </div>
<div class="line"><a name="l00976"></a><span class="lineno">  976</span>&#160;    <span class="keywordflow">return</span> <a class="code" href="QuEST__common_8c.html#ae0cfea24091c8336146aa84c2253992e">statevec_calcExpecPauliSum</a>(qureg, hamil.<a class="code" href="structPauliHamil.html#a4b8d38c403553c07ceddcd40c46ce6c8">pauliCodes</a>, hamil.<a class="code" href="structPauliHamil.html#ac1c6c9f6299cf83bbba88123216c3cac">termCoeffs</a>, hamil.<a class="code" href="structPauliHamil.html#a737e46b40ef8990cf004d22eb9dbe2e4">numSumTerms</a>, workspace);</div>
<div class="line"><a name="l00977"></a><span class="lineno">  977</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00166">PauliHamil::numSumTerms</a>, <a class="el" href="QuEST_8h_source.html#l00162">PauliHamil::pauliCodes</a>, <a class="el" href="QuEST__common_8c_source.html#l00480">statevec_calcExpecPauliSum()</a>, <a class="el" href="QuEST_8h_source.html#l00164">PauliHamil::termCoeffs</a>, <a class="el" href="QuEST__validation_8c_source.html#l00495">validateMatchingQuregDims()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00624">validateMatchingQuregPauliHamilDims()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00499">validateMatchingQuregTypes()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00619">validatePauliHamil()</a>.</p>

<p class="reference">Referenced by <a class="el" href="test__calculations_8cpp_source.html#l00183">TEST_CASE()</a>.</p>

</div>
</div>
<a id="ga15cfad3f3d26339128e3be32ae7deacd"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga15cfad3f3d26339128e3be32ae7deacd">&#9670;&nbsp;</a></span>calcExpecPauliProd()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> calcExpecPauliProd </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>targetQubits</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">enum <a class="el" href="group__type.html#ga1c703cf89629e4e9c7023cd402d67028">pauliOpType</a> *&#160;</td>
          <td class="paramname"><em>pauliCodes</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numTargets</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>workspace</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Computes the expected value of a product of Pauli operators. </p>
<p>Letting <img class="formulaInl" alt="$ \sigma = \otimes_j \hat{\sigma}_j $" src="form_128.png"/> be the operators indicated by <code>pauliCodes</code> and acting on qubits <code>targetQubits</code>, this function computes <img class="formulaInl" alt="$ \langle \psi | \sigma | \psi \rangle $" src="form_129.png"/> if <code>qureg</code> = <img class="formulaInl" alt="$ \psi $" src="form_37.png"/> is a statevector, and computes <img class="formulaInl" alt="$ \text{Trace}(\sigma \rho) $" src="form_130.png"/> if <code>qureg</code> = <img class="formulaInl" alt="$ \rho $" src="form_39.png"/> is a density matrix.</p>
<p><code>pauliCodes</code> is an array of length <code>numTargets</code> which specifies which Pauli operators to enact on the corresponding qubits in <code>targetQubits</code>, where 0 = <code>PAULI_I</code>, 1 = <code>PAULI_X</code>, 2 = <code>PAULI_Y</code>, 3 = <code>PAULI_Z</code>. The target qubits must be unique, and at most <code>qureg.numQubitsRepresented</code> may be specified. For example, on a 7-qubit statevector, </p><pre class="fragment">calcExpecPauliProd(qureg, {4,5,6}, {PAULI_X, PAULI_I, PAULI_Z}, 3, workspace);
</pre><p>will compute <img class="formulaInl" alt="$ \langle \psi | I I I I X I Z | \psi \rangle $" src="form_131.png"/> (where in this notation, the left-most operator applies to the least-significant qubit, i.e. that with index 0).</p>
<p><code>workspace</code> must be a register with the same type (statevector vs density matrix) and dimensions (number of represented qubits) as <code>qureg</code>, and is used as working space. When this function returns, <code>qureg</code> will be unchanged and <code>workspace</code> will be set to <img class="formulaInl" alt="$ \sigma | \psi \rangle $" src="form_132.png"/> (if <code>qureg</code> is a statevector) or <img class="formulaInl" alt="$ \sigma \rho $" src="form_133.png"/> (if <code>qureg</code> is a density matrix). NOTE that this last quantity is NOT the result of applying the paulis as unitaries, <img class="formulaInl" alt="$ \sigma^\dagger \rho \sigma $" src="form_134.png"/>, but is instead the result of their direct multiplication with the density matrix. It is therefore itself not a valid density matrix.</p>
<p>This function works by cloning the <code>qureg</code> state into <code>workspace</code>, applying the specified Pauli operators to <code>workspace</code> then computing its inner product with <code>qureg</code> (for statevectors) or its trace (for density matrices). It therefore should scale linearly in time with the number of specified non-identity Pauli operators, which is bounded by the number of represented qubits.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">qureg</td><td>the register of which to find the expected value, which is unchanged by this function </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">targetQubits</td><td>a list of the indices of the target qubits </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">pauliCodes</td><td>a list of the Pauli codes (0=PAULI_I, 1=PAULI_X, 2=PAULI_Y, 3=PAULI_Z) to apply to the corresponding qubits in <code>targetQubits</code> </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">numTargets</td><td>number of target qubits, i.e. the length of <code>targetQubits</code> and <code>pauliCodes</code> </td></tr>
    <tr><td class="paramdir">[in,out]</td><td class="paramname">workspace</td><td>a working-space qureg with the same dimensions as <code>qureg</code>, which is modified to be the result of multiplying the state with the pauli operators </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname">invalidQuESTInputError</td><td>if <code>numTargets</code> is outside [1, <code>qureg.numQubitsRepresented</code>]), or if any qubit in <code>targetQubits</code> is outside [0, <code>qureg.numQubitsRepresented</code>)) or if any qubit in <code>targetQubits</code> is repeated, or if any code in <code>pauliCodes</code> is not in {0,1,2,3}, or if <code>workspace</code> is not of the same type and dimensions as <code>qureg</code> </td></tr>
  </table>
  </dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="QuEST_8c_source.html#l00952">952</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00952"></a><span class="lineno">  952</span>&#160;                                                                                                                        {</div>
<div class="line"><a name="l00953"></a><span class="lineno">  953</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a6776217a5f7ba38b56175cf6db0f96e0">validateMultiTargets</a>(qureg, targetQubits, numTargets, __func__);</div>
<div class="line"><a name="l00954"></a><span class="lineno">  954</span>&#160;    <a class="code" href="QuEST__validation_8c.html#aa194ba5f5c6e19c6caa4c715b3dbefcc">validatePauliCodes</a>(pauliCodes, numTargets, __func__);</div>
<div class="line"><a name="l00955"></a><span class="lineno">  955</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a031812e1cf2c98d72d795cea7bbe73a5">validateMatchingQuregTypes</a>(qureg, workspace, __func__);</div>
<div class="line"><a name="l00956"></a><span class="lineno">  956</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a87d22240ccfd81827a2a34b8d569d347">validateMatchingQuregDims</a>(qureg, workspace, __func__);</div>
<div class="line"><a name="l00957"></a><span class="lineno">  957</span>&#160;    </div>
<div class="line"><a name="l00958"></a><span class="lineno">  958</span>&#160;    <span class="keywordflow">return</span> <a class="code" href="QuEST__common_8c.html#aef380928d1b0003411d6159ca6594cd5">statevec_calcExpecPauliProd</a>(qureg, targetQubits, pauliCodes, numTargets, workspace);</div>
<div class="line"><a name="l00959"></a><span class="lineno">  959</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__common_8c_source.html#l00465">statevec_calcExpecPauliProd()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00495">validateMatchingQuregDims()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00499">validateMatchingQuregTypes()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00392">validateMultiTargets()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00563">validatePauliCodes()</a>.</p>

<p class="reference">Referenced by <a class="el" href="test__calculations_8cpp_source.html#l00296">TEST_CASE()</a>.</p>

</div>
</div>
<a id="ga50ee589fd5ceab52fdd70d0082352b41"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga50ee589fd5ceab52fdd70d0082352b41">&#9670;&nbsp;</a></span>calcExpecPauliSum()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> calcExpecPauliSum </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">enum <a class="el" href="group__type.html#ga1c703cf89629e4e9c7023cd402d67028">pauliOpType</a> *&#160;</td>
          <td class="paramname"><em>allPauliCodes</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *&#160;</td>
          <td class="paramname"><em>termCoeffs</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numSumTerms</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>workspace</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Computes the expected value of a sum of products of Pauli operators. </p>
<p>Let <img class="formulaInl" alt="$ H = \sum_i c_i \otimes_j^{N} \hat{\sigma}_{i,j} $" src="form_135.png"/> be the operators indicated by <code>allPauliCodes</code> (where <img class="formulaInl" alt="$ c_i \in $" src="form_136.png"/> <code>termCoeffs</code> and <img class="formulaInl" alt="$ N = $" src="form_137.png"/> <code>qureg.numQubitsRepresented</code>). This function computes <img class="formulaInl" alt="$ \langle \psi | H | \psi \rangle $" src="form_138.png"/> if <code>qureg</code> = <img class="formulaInl" alt="$ \psi $" src="form_37.png"/> is a statevector, and computes <img class="formulaInl" alt="$ \text{Trace}(H \rho) =\text{Trace}(\rho H) $" src="form_139.png"/> if <code>qureg</code> = <img class="formulaInl" alt="$ \rho $" src="form_39.png"/> is a density matrix.</p>
<p><code>allPauliCodes</code> is an array of length <code>numSumTerms*<code>qureg.numQubitsRepresented</code> which</code> specifies which Pauli operators to apply, where 0 = <code>PAULI_I</code>, 1 = <code>PAULI_X</code>, 2 = <code>PAULI_Y</code>, 3 = <code>PAULI_Z</code>. For each sum term, a Pauli operator must be specified for EVERY qubit in <code>qureg</code>; each set of <code>numSumTerms</code> operators will be grouped into a product. <code>termCoeffs</code> is an arrray of length <code>numSumTerms</code> containing the term coefficients. For example, on a 3-qubit statevector, </p><pre class="fragment">int paulis[6] = {PAULI_X, PAULI_I, PAULI_I,  PAULI_X, PAULI_Y, PAULI_Z};
qreal coeffs[2] = {1.5, -3.6};
calcExpecPauliSum(qureg, paulis, coeffs, 2, workspace);
</pre><p>will compute <img class="formulaInl" alt="$ \langle \psi | (1.5 X I I - 3.6 X Y Z) | \psi \rangle $" src="form_140.png"/> (where in this notation, the left-most operator applies to the least-significant qubit, i.e. that with index 0).</p>
<p><code>workspace</code> must be a register with the same type (statevector vs density matrix) and dimensions (number of represented qubits) as <code>qureg</code>, and is used as working space. When this function returns, <code>qureg</code> will be unchanged and <code>workspace</code> will be set to <code>qureg</code> pre-multiplied with the final Pauli product. NOTE that if <code>qureg</code> is a density matrix, <code>workspace</code> will become <img class="formulaInl" alt="$ \hat{\sigma} \rho $" src="form_141.png"/> which is itself not a density matrix (it is distinct from <img class="formulaInl" alt="$ \hat{\sigma} \rho \hat{\sigma}^\dagger $" src="form_181.png"/>).</p>
<p>This function works by cloning the <code>qureg</code> state into <code>workspace</code>, applying each of the specified Pauli products to <code>workspace</code> (one Pauli operation at a time), then computing its inner product with <code>qureg</code> (for statevectors) or its trace (for density matrices) multiplied with the corresponding coefficient, and summing these contributions. It therefore should scale linearly in time with the total number of non-identity specified Pauli operators.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">qureg</td><td>the register of which to find the expected value, which is unchanged by this function </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">allPauliCodes</td><td>a list of the Pauli codes (0=PAULI_I, 1=PAULI_X, 2=PAULI_Y, 3=PAULI_Z) of all Paulis involved in the products of terms. A Pauli must be specified for each qubit in the register, in every term of the sum. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">termCoeffs</td><td>The coefficients of each term in the sum of Pauli products </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">numSumTerms</td><td>The total number of Pauli products specified </td></tr>
    <tr><td class="paramdir">[in,out]</td><td class="paramname">workspace</td><td>a working-space qureg with the same dimensions as <code>qureg</code>, which is modified to be the result of multiplying the state with the final specified Pauli product </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname">invalidQuESTInputError</td><td>if any code in <code>allPauliCodes</code> is not in {0,1,2,3}, or if numSumTerms &lt;= 0, or if <code>workspace</code> is not of the same type and dimensions as <code>qureg</code> </td></tr>
  </table>
  </dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="QuEST_8c_source.html#l00961">961</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00961"></a><span class="lineno">  961</span>&#160;                                                                                                                           {</div>
<div class="line"><a name="l00962"></a><span class="lineno">  962</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a5be128290a7bba9a7f12d32cabe2276b">validateNumPauliSumTerms</a>(numSumTerms, __func__);</div>
<div class="line"><a name="l00963"></a><span class="lineno">  963</span>&#160;    <a class="code" href="QuEST__validation_8c.html#aa194ba5f5c6e19c6caa4c715b3dbefcc">validatePauliCodes</a>(allPauliCodes, numSumTerms*qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>, __func__);</div>
<div class="line"><a name="l00964"></a><span class="lineno">  964</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a031812e1cf2c98d72d795cea7bbe73a5">validateMatchingQuregTypes</a>(qureg, workspace, __func__);</div>
<div class="line"><a name="l00965"></a><span class="lineno">  965</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a87d22240ccfd81827a2a34b8d569d347">validateMatchingQuregDims</a>(qureg, workspace, __func__);</div>
<div class="line"><a name="l00966"></a><span class="lineno">  966</span>&#160;    </div>
<div class="line"><a name="l00967"></a><span class="lineno">  967</span>&#160;    <span class="keywordflow">return</span> <a class="code" href="QuEST__common_8c.html#ae0cfea24091c8336146aa84c2253992e">statevec_calcExpecPauliSum</a>(qureg, allPauliCodes, termCoeffs, numSumTerms, workspace);</div>
<div class="line"><a name="l00968"></a><span class="lineno">  968</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00208">Qureg::numQubitsRepresented</a>, <a class="el" href="QuEST__common_8c_source.html#l00480">statevec_calcExpecPauliSum()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00495">validateMatchingQuregDims()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00499">validateMatchingQuregTypes()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00570">validateNumPauliSumTerms()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00563">validatePauliCodes()</a>.</p>

<p class="reference">Referenced by <a class="el" href="test__calculations_8cpp_source.html#l00438">TEST_CASE()</a>.</p>

</div>
</div>
<a id="gaa266ed6c8ae5d0d0f49e1ac50819cffc"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaa266ed6c8ae5d0d0f49e1ac50819cffc">&#9670;&nbsp;</a></span>calcFidelity()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> calcFidelity </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>pureState</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Calculates the fidelity of <code>qureg</code> (a statevector or density matrix) against a reference pure state (necessarily a statevector). </p>
<p>If <code>qureg</code> is a state-vector, this function computes </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ |\langle \text{qureg} | \text{pureState} \rangle|^2 \]" src="form_113.png"/>
</p>
<p> If <code>qureg</code> is a density matrix, this function computes </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ \langle \text{pureState} | \text{qureg} | \text{pureState} \rangle \]" src="form_114.png"/>
</p>
<p> In either case, the returned fidelity lies in [0, 1] (assuming both input states have valid normalisation). If any of the input <code>Quregs</code> are not normalised, this function will return the real component of the correct linear algebra calculation.</p>
<p>The number of qubits represented in <code>qureg</code> and <code>pureState</code> must match.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">qureg</td><td>a density matrix or state vector </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">pureState</td><td>a state vector </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>the fidelity between the input registers </dd></dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname">invalidQuESTInputError</td><td>if the second argument (<code>pureState</code>) is not a statevector, or if the number of qubits in <code>qureg</code> and <code>pureState</code> do not match </td></tr>
  </table>
  </dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="QuEST_8c_source.html#l00942">942</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00942"></a><span class="lineno">  942</span>&#160;                                                 {</div>
<div class="line"><a name="l00943"></a><span class="lineno">  943</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a7adc86571f1154558676d95daf0cbd1f">validateSecondQuregStateVec</a>(pureState, __func__);</div>
<div class="line"><a name="l00944"></a><span class="lineno">  944</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a87d22240ccfd81827a2a34b8d569d347">validateMatchingQuregDims</a>(qureg, pureState, __func__);</div>
<div class="line"><a name="l00945"></a><span class="lineno">  945</span>&#160;    </div>
<div class="line"><a name="l00946"></a><span class="lineno">  946</span>&#160;    <span class="keywordflow">if</span> (qureg.<a class="code" href="structQureg.html#acf78445e9435d09f44f0cc832c6aee79">isDensityMatrix</a>)</div>
<div class="line"><a name="l00947"></a><span class="lineno">  947</span>&#160;        <span class="keywordflow">return</span> <a class="code" href="QuEST__internal_8h.html#aa6c3f86010ad398f42b0577ea3bb5bcf">densmatr_calcFidelity</a>(qureg, pureState);</div>
<div class="line"><a name="l00948"></a><span class="lineno">  948</span>&#160;    <span class="keywordflow">else</span></div>
<div class="line"><a name="l00949"></a><span class="lineno">  949</span>&#160;        <span class="keywordflow">return</span> <a class="code" href="QuEST__common_8c.html#aeeec9fe1501e25930adf6c38763a158e">statevec_calcFidelity</a>(qureg, pureState);</div>
<div class="line"><a name="l00950"></a><span class="lineno">  950</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00415">densmatr_calcFidelity()</a>, <a class="el" href="QuEST_8h_source.html#l00206">Qureg::isDensityMatrix</a>, <a class="el" href="QuEST__common_8c_source.html#l00377">statevec_calcFidelity()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00495">validateMatchingQuregDims()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00503">validateSecondQuregStateVec()</a>.</p>

<p class="reference">Referenced by <a class="el" href="test__calculations_8cpp_source.html#l00554">TEST_CASE()</a>.</p>

</div>
</div>
<a id="ga87ddbe5c8281543541ccd99e0dafd387"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga87ddbe5c8281543541ccd99e0dafd387">&#9670;&nbsp;</a></span>calcHilbertSchmidtDistance()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> calcHilbertSchmidtDistance </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>a</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>b</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Computes the Hilbert Schmidt distance between two density matrices <code>a</code> and <code>b</code>, defined as the Frobenius norm of the difference between them. </p>
<p>That is, we define the Hilbert Schmidt distance </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ D(a, b) = \| a - b \|_F = \sqrt{ \text{Tr}[ (a-b)(a-b)^\dagger ] } \]" src="form_161.png"/>
</p>
<p> This is equivalent to the square-root of the sum of the absolute value squared of the element-differences of the matrices, i.e. </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ D(a, b) = \sqrt{ \sum\limits_i \sum\limits_j | a_{ij} - b_{ij} |^2 } \]" src="form_162.png"/>
</p>
<p> We caution this may differ by some definitions of the Hilbert Schmidt distance by a square-root.</p>
<p>This function correctly returns the result of the above formulations even when <code>a</code> and <code>b</code> are incorrectly normalised (i.e. are general matrices).</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">a</td><td>a density matrix </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">b</td><td>an equally-sized density matrix </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname">invalidQuESTInputError</td><td>if either <code>a</code> or <code>b</code> are not density matrices, or if <code>a</code> and <code>have</code> mismatching dimensions. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Balint Koczor </dd>
<dd>
Tyson Jones (refactored, doc) </dd></dl>

<p class="definition">Definition at line <a class="el" href="QuEST_8c_source.html#l00988">988</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00988"></a><span class="lineno">  988</span>&#160;                                                   {</div>
<div class="line"><a name="l00989"></a><span class="lineno">  989</span>&#160;    <a class="code" href="QuEST__validation_8c.html#af22919f5190ca1b3b6b52b8f2fb8213b">validateDensityMatrQureg</a>(a, __func__);</div>
<div class="line"><a name="l00990"></a><span class="lineno">  990</span>&#160;    <a class="code" href="QuEST__validation_8c.html#af22919f5190ca1b3b6b52b8f2fb8213b">validateDensityMatrQureg</a>(b, __func__);</div>
<div class="line"><a name="l00991"></a><span class="lineno">  991</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a87d22240ccfd81827a2a34b8d569d347">validateMatchingQuregDims</a>(a, b, __func__);</div>
<div class="line"><a name="l00992"></a><span class="lineno">  992</span>&#160;    </div>
<div class="line"><a name="l00993"></a><span class="lineno">  993</span>&#160;    <span class="keywordflow">return</span> <a class="code" href="QuEST__internal_8h.html#a8c9da88f734b0862f4cce7d819e6d3b5">densmatr_calcHilbertSchmidtDistance</a>(a, b);</div>
<div class="line"><a name="l00994"></a><span class="lineno">  994</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00430">densmatr_calcHilbertSchmidtDistance()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00483">validateDensityMatrQureg()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00495">validateMatchingQuregDims()</a>.</p>

<p class="reference">Referenced by <a class="el" href="test__calculations_8cpp_source.html#l00706">TEST_CASE()</a>.</p>

</div>
</div>
<a id="ga374ad70804998394ae41ebfe106258a6"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga374ad70804998394ae41ebfe106258a6">&#9670;&nbsp;</a></span>calcInnerProduct()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="structComplex.html">Complex</a> calcInnerProduct </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>bra</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>ket</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Computes the inner product <img class="formulaInl" alt="$ \langle \text{bra} | \text{ket} \rangle $" src="form_84.png"/> of two equal-size state vectors, given by. </p>
<p class="formulaDsp">
<img class="formulaDsp" alt="\[ \langle \text{bra} | \text{ket} \rangle = \sum_i {\text{bra}_i}^* \; \times \; \text{ket}_i \]" src="form_85.png"/>
</p>
<p> The same <code>qureg</code> may be passed as both <code>bra</code> and <code>ket</code>, though we recommend users check state-vector normalisation with <code>calcTotalProb</code> which employs Kahan summation for greater accuracy. Neither state-vector is modified.</p>
<p>This function returns the correct inner product even if <code>bra</code> and <code>ket</code> are not correctly normalised states.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">bra</td><td>qureg to be the 'bra' (i.e. have its values conjugate transposed) in the inner product </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">ket</td><td>qureg to be the 'ket' in the inner product </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>the complex inner product of <code>bra</code> and <code>ket</code> </dd></dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname">invalidQuESTInputError</td><td>if either <code>bra</code> or <code>ket</code> are not state-vectors, or if <code>bra</code> and <code>ket</code> do not have equal dimensions. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="QuEST_8c_source.html#l00910">910</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00910"></a><span class="lineno">  910</span>&#160;                                               {</div>
<div class="line"><a name="l00911"></a><span class="lineno">  911</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a72feec2aaa05f98aed7f3c3fee141251">validateStateVecQureg</a>(bra, __func__);</div>
<div class="line"><a name="l00912"></a><span class="lineno">  912</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a72feec2aaa05f98aed7f3c3fee141251">validateStateVecQureg</a>(ket, __func__);</div>
<div class="line"><a name="l00913"></a><span class="lineno">  913</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a87d22240ccfd81827a2a34b8d569d347">validateMatchingQuregDims</a>(bra, ket,  __func__);</div>
<div class="line"><a name="l00914"></a><span class="lineno">  914</span>&#160;    </div>
<div class="line"><a name="l00915"></a><span class="lineno">  915</span>&#160;    <span class="keywordflow">return</span> <a class="code" href="QuEST__internal_8h.html#a7ebd3198a198f4cd20840f64fd8b84d0">statevec_calcInnerProduct</a>(bra, ket);</div>
<div class="line"><a name="l00916"></a><span class="lineno">  916</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00035">statevec_calcInnerProduct()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00495">validateMatchingQuregDims()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00479">validateStateVecQureg()</a>.</p>

<p class="reference">Referenced by <a class="el" href="test__calculations_8cpp_source.html#l00802">TEST_CASE()</a>.</p>

</div>
</div>
<a id="ga2a7946e6fa4f44c9ae0c6c9f683229ad"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga2a7946e6fa4f44c9ae0c6c9f683229ad">&#9670;&nbsp;</a></span>calcProbOfOutcome()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> calcProbOfOutcome </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>measureQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>outcome</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Gives the probability of a specified qubit being measured in the given outcome (0 or 1). </p>
<p>This performs no actual measurement and does not change the state of the qubits.</p>
<p>For state-vectors, this function works by summing the absolute-value-squared of every amplitude in the state-vector for which <code>measureQubit</code> <code>=</code> <code>0</code>. If <code>outcome</code> <code>=</code> <code>1</code>, it returns <code>1</code> minus this value. Hence for unnormalised state-vectors, this result will differ from the absolute-value-squared of every amplitude where <code>measureQubit</code> <code>=</code> <code>outcome</code>.</p>
<p>For density matrices, this function sums the diagonal values (should be real) corresponding to <code>measureQubit</code> <code>=</code> <code>0</code> (returning 1 minus this if <code>outcome</code> <code>=</code> <code>1</code>).</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">qureg</td><td>object representing the set of all qubits </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">measureQubit</td><td>qubit to study </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">outcome</td><td>for which to find the probability of the qubit being measured in </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>probability of qubit measureQubit being measured in the given outcome </dd></dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname">invalidQuESTInputError</td><td>if <code>measureQubit</code> is outside [0, <code>qureg.numQubitsRepresented</code>), or if <code>outcome</code> is not in {0, 1}. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Ania Brown (state-vector) </dd>
<dd>
Tyson Jones (density matrix) </dd></dl>

<p class="definition">Definition at line <a class="el" href="QuEST_8c_source.html#l00926">926</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00926"></a><span class="lineno">  926</span>&#160;                                                                    {</div>
<div class="line"><a name="l00927"></a><span class="lineno">  927</span>&#160;    <a class="code" href="QuEST__validation_8c.html#ac31c45c5a31c523be0eb26abba6cf598">validateTarget</a>(qureg, measureQubit, __func__);</div>
<div class="line"><a name="l00928"></a><span class="lineno">  928</span>&#160;    <a class="code" href="QuEST__validation_8c.html#ad613c75ff252a88e54f911053bd2032c">validateOutcome</a>(outcome, __func__);</div>
<div class="line"><a name="l00929"></a><span class="lineno">  929</span>&#160;    </div>
<div class="line"><a name="l00930"></a><span class="lineno">  930</span>&#160;    <span class="keywordflow">if</span> (qureg.<a class="code" href="structQureg.html#acf78445e9435d09f44f0cc832c6aee79">isDensityMatrix</a>)</div>
<div class="line"><a name="l00931"></a><span class="lineno">  931</span>&#160;        <span class="keywordflow">return</span> <a class="code" href="QuEST__internal_8h.html#ae37b3eff5d3affbc1edfe216cabc1c53">densmatr_calcProbOfOutcome</a>(qureg, measureQubit, outcome);</div>
<div class="line"><a name="l00932"></a><span class="lineno">  932</span>&#160;    <span class="keywordflow">else</span></div>
<div class="line"><a name="l00933"></a><span class="lineno">  933</span>&#160;        <span class="keywordflow">return</span> <a class="code" href="QuEST__internal_8h.html#a63cb88a5f4eb12fef087435b8db3f8eb">statevec_calcProbOfOutcome</a>(qureg, measureQubit, outcome);</div>
<div class="line"><a name="l00934"></a><span class="lineno">  934</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01276">densmatr_calcProbOfOutcome()</a>, <a class="el" href="QuEST_8h_source.html#l00206">Qureg::isDensityMatrix</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01260">statevec_calcProbOfOutcome()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00487">validateOutcome()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00364">validateTarget()</a>.</p>

<p class="reference">Referenced by <a class="el" href="test__calculations_8cpp_source.html#l00877">TEST_CASE()</a>.</p>

</div>
</div>
<a id="ga683779343fb2c6055f6b1d01079c2ede"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga683779343fb2c6055f6b1d01079c2ede">&#9670;&nbsp;</a></span>calcPurity()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> calcPurity </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Calculates the purity of a density matrix, by the trace of the density matrix squared. </p>
<p>Returns <img class="formulaInl" alt="$\text{Tr}(\rho^2)$" src="form_111.png"/>. For a pure state, this =1. For a mixed state, the purity is less than 1 and is lower bounded by 1/2^n, where n is the number of qubits. The minimum purity is achieved for the maximally mixed state identity/2^n.</p>
<p>This function does not accept state-vectors, which clearly have purity 1.</p>
<p>Note this function will give incorrect results for non-Hermitian Quregs (i.e. invalid density matrices), which will disagree with <img class="formulaInl" alt="$\text{Tr}(\rho^2)$" src="form_111.png"/>. Instead, this function returns <img class="formulaInl" alt="$\sum_{ij} |\rho_{ij}|^2 $" src="form_112.png"/>.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">qureg</td><td>a density matrix of which to measure the purity </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>the purity </dd></dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname">invalidQuESTInputError</td><td>if either <code>combineQureg</code> or <code>otherQureg</code> are not density matrices, or if the dimensions of <code>combineQureg</code> and <code>otherQureg</code> do not match, or if <code>prob</code> is not in [0, 1] </td></tr>
  </table>
  </dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="QuEST_8c_source.html#l00936">936</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00936"></a><span class="lineno">  936</span>&#160;                              {</div>
<div class="line"><a name="l00937"></a><span class="lineno">  937</span>&#160;    <a class="code" href="QuEST__validation_8c.html#af22919f5190ca1b3b6b52b8f2fb8213b">validateDensityMatrQureg</a>(qureg, __func__);</div>
<div class="line"><a name="l00938"></a><span class="lineno">  938</span>&#160;    </div>
<div class="line"><a name="l00939"></a><span class="lineno">  939</span>&#160;    <span class="keywordflow">return</span> <a class="code" href="QuEST__internal_8h.html#ae45eefa65f4ecd37bab84fade7cf7f1f">densmatr_calcPurity</a>(qureg);</div>
<div class="line"><a name="l00940"></a><span class="lineno">  940</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01288">densmatr_calcPurity()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00483">validateDensityMatrQureg()</a>.</p>

<p class="reference">Referenced by <a class="el" href="test__calculations_8cpp_source.html#l01000">TEST_CASE()</a>.</p>

</div>
</div>
<a id="gab082910d33473ec29e1d5852943de468"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gab082910d33473ec29e1d5852943de468">&#9670;&nbsp;</a></span>calcTotalProb()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> calcTotalProb </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>A debugging function which calculates the probability of the qubits in <code>qureg</code> being in any state, which should always be 1 for correctly normalised states (hence returning a real number). </p>
<p>For state-vectors <img class="formulaInl" alt="$ \psi $" src="form_37.png"/>, this is the norm of the entire state-vector (the sum of the absolute-value-squared of every amplitude): </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ \sum\limits_i |\psi_i|^2 \]" src="form_38.png"/>
</p>
<p> and for density matrices <img class="formulaInl" alt="$ \rho $" src="form_39.png"/>, it is the trace: </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ \text{Trace}(\rho) = \sum\limits_i \rho_{i,i} \; \]" src="form_40.png"/>
</p>
<p>For un-normalised density matrices (those directly modified or initialised by the user), this function returns the real component of the trace.</p>
<p>Note this calculation utilises Kahan summation for greater accuracy, and hence is not parallelised and so will be slower than other functions.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">qureg</td><td>object representing a set of qubits </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>the total probability of the qubits in <code>qureg</code> being in any state </dd></dl>
<dl class="section author"><dt>Author</dt><dd>Ania Brown (state-vector) </dd>
<dd>
Tyson Jones (density matrix, doc) </dd></dl>

<p class="definition">Definition at line <a class="el" href="QuEST_8c_source.html#l00903">903</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00903"></a><span class="lineno">  903</span>&#160;                                 {</div>
<div class="line"><a name="l00904"></a><span class="lineno">  904</span>&#160;    <span class="keywordflow">if</span> (qureg.<a class="code" href="structQureg.html#acf78445e9435d09f44f0cc832c6aee79">isDensityMatrix</a>)  </div>
<div class="line"><a name="l00905"></a><span class="lineno">  905</span>&#160;            <span class="keywordflow">return</span> <a class="code" href="QuEST__internal_8h.html#a6153547f245c05874161a105e9a2f02c">densmatr_calcTotalProb</a>(qureg);</div>
<div class="line"><a name="l00906"></a><span class="lineno">  906</span>&#160;        <span class="keywordflow">else</span></div>
<div class="line"><a name="l00907"></a><span class="lineno">  907</span>&#160;            <span class="keywordflow">return</span> <a class="code" href="QuEST__internal_8h.html#ad65ad1b5ea6f30b0c6b4ffda96e1a8e6">statevec_calcTotalProb</a>(qureg);</div>
<div class="line"><a name="l00908"></a><span class="lineno">  908</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00053">densmatr_calcTotalProb()</a>, <a class="el" href="QuEST_8h_source.html#l00206">Qureg::isDensityMatrix</a>, and <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00088">statevec_calcTotalProb()</a>.</p>

<p class="reference">Referenced by <a class="el" href="test__calculations_8cpp_source.html#l01072">TEST_CASE()</a>.</p>

</div>
</div>
<a id="ga30d6f8b7c766c9c9914b2c61a2fc0def"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga30d6f8b7c766c9c9914b2c61a2fc0def">&#9670;&nbsp;</a></span>getAmp()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="structComplex.html">Complex</a> getAmp </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">long long int&#160;</td>
          <td class="paramname"><em>index</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Get the complex amplitude at a given index in the state vector. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">qureg</td><td>object representing a set of qubits </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">index</td><td>index in state vector of probability amplitudes </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>amplitude at index, returned as a <a class="el" href="structComplex.html" title="Represents one complex number.">Complex</a> struct (with .real and .imag attributes) </dd></dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname">invalidQuESTInputError</td><td>if <code>qureg</code> is a density matrix, or if <code>index</code> is outside [0, <img class="formulaInl" alt="$2^{N}$" src="form_35.png"/>) where <img class="formulaInl" alt="$N = $" src="form_36.png"/> <code>qureg.numQubitsRepresented</code> </td></tr>
  </table>
  </dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="QuEST_8c_source.html#l00699">699</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00699"></a><span class="lineno">  699</span>&#160;                                                 {</div>
<div class="line"><a name="l00700"></a><span class="lineno">  700</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a72feec2aaa05f98aed7f3c3fee141251">validateStateVecQureg</a>(qureg, __func__);</div>
<div class="line"><a name="l00701"></a><span class="lineno">  701</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a5f87419b253a97f6caadb72b507b9853">validateAmpIndex</a>(qureg, index, __func__);</div>
<div class="line"><a name="l00702"></a><span class="lineno">  702</span>&#160;    </div>
<div class="line"><a name="l00703"></a><span class="lineno">  703</span>&#160;    <a class="code" href="structComplex.html">Complex</a> amp;</div>
<div class="line"><a name="l00704"></a><span class="lineno">  704</span>&#160;    amp.<a class="code" href="structComplex.html#ab5b2e2eca02131fc74b289a83636cbe3">real</a> = <a class="code" href="QuEST__internal_8h.html#abc9a9ef4344c7faaaf28ac25c76649b9">statevec_getRealAmp</a>(qureg, index);</div>
<div class="line"><a name="l00705"></a><span class="lineno">  705</span>&#160;    amp.<a class="code" href="structComplex.html#a84f5439aad0ef495efdd3b4c1c02d27e">imag</a> = <a class="code" href="QuEST__internal_8h.html#abd509244d57657e148e4084c5ab5d28f">statevec_getImagAmp</a>(qureg, index);</div>
<div class="line"><a name="l00706"></a><span class="lineno">  706</span>&#160;    <span class="keywordflow">return</span> amp;</div>
<div class="line"><a name="l00707"></a><span class="lineno">  707</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00106">Complex::imag</a>, <a class="el" href="QuEST_8h_source.html#l00105">Complex::real</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00208">statevec_getImagAmp()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00198">statevec_getRealAmp()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00346">validateAmpIndex()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00479">validateStateVecQureg()</a>.</p>

<p class="reference">Referenced by <a class="el" href="test__calculations_8cpp_source.html#l01139">TEST_CASE()</a>.</p>

</div>
</div>
<a id="gadca286c4ad5cde6124d4e80a7ab95a68"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gadca286c4ad5cde6124d4e80a7ab95a68">&#9670;&nbsp;</a></span>getDensityAmp()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="structComplex.html">Complex</a> getDensityAmp </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">long long int&#160;</td>
          <td class="paramname"><em>row</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">long long int&#160;</td>
          <td class="paramname"><em>col</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Get an amplitude from a density matrix at a given row and column. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">qureg</td><td>object representing a density matrix </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">row</td><td>row of the desired amplitude in the density matrix </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">col</td><td>column of the desired amplitude in the density matrix </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>a <a class="el" href="structComplex.html" title="Represents one complex number.">Complex</a> scalar representing the desired amplitude </dd></dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname">invalidQuESTInputError</td><td>if <code>qureg</code> is a statevector, or if <code>row</code> or <code>col</code> are outside [0, <img class="formulaInl" alt="$2^{N}$" src="form_35.png"/>) where <img class="formulaInl" alt="$N = $" src="form_36.png"/> <code>qureg.numQubitsRepresented</code> </td></tr>
  </table>
  </dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="QuEST_8c_source.html#l00709">709</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00709"></a><span class="lineno">  709</span>&#160;                                                                         {</div>
<div class="line"><a name="l00710"></a><span class="lineno">  710</span>&#160;    <a class="code" href="QuEST__validation_8c.html#af22919f5190ca1b3b6b52b8f2fb8213b">validateDensityMatrQureg</a>(qureg, __func__);</div>
<div class="line"><a name="l00711"></a><span class="lineno">  711</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a5f87419b253a97f6caadb72b507b9853">validateAmpIndex</a>(qureg, row, __func__);</div>
<div class="line"><a name="l00712"></a><span class="lineno">  712</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a5f87419b253a97f6caadb72b507b9853">validateAmpIndex</a>(qureg, col, __func__);</div>
<div class="line"><a name="l00713"></a><span class="lineno">  713</span>&#160;    </div>
<div class="line"><a name="l00714"></a><span class="lineno">  714</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> ind = row + col*(1LL &lt;&lt; qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00715"></a><span class="lineno">  715</span>&#160;    <a class="code" href="structComplex.html">Complex</a> amp;</div>
<div class="line"><a name="l00716"></a><span class="lineno">  716</span>&#160;    amp.<a class="code" href="structComplex.html#ab5b2e2eca02131fc74b289a83636cbe3">real</a> = <a class="code" href="QuEST__internal_8h.html#abc9a9ef4344c7faaaf28ac25c76649b9">statevec_getRealAmp</a>(qureg, ind);</div>
<div class="line"><a name="l00717"></a><span class="lineno">  717</span>&#160;    amp.imag = <a class="code" href="QuEST__internal_8h.html#abd509244d57657e148e4084c5ab5d28f">statevec_getImagAmp</a>(qureg, ind);</div>
<div class="line"><a name="l00718"></a><span class="lineno">  718</span>&#160;    <span class="keywordflow">return</span> amp;</div>
<div class="line"><a name="l00719"></a><span class="lineno">  719</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00208">Qureg::numQubitsRepresented</a>, <a class="el" href="QuEST_8h_source.html#l00105">Complex::real</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00208">statevec_getImagAmp()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00198">statevec_getRealAmp()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00346">validateAmpIndex()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00483">validateDensityMatrQureg()</a>.</p>

<p class="reference">Referenced by <a class="el" href="test__calculations_8cpp_source.html#l01178">TEST_CASE()</a>.</p>

</div>
</div>
<a id="gad575782de461d9ab0975b38cc7850f1a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gad575782de461d9ab0975b38cc7850f1a">&#9670;&nbsp;</a></span>getImagAmp()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> getImagAmp </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">long long int&#160;</td>
          <td class="paramname"><em>index</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Get the imaginary component of the complex probability amplitude at an index in the state vector. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">qureg</td><td>object representing a set of qubits </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">index</td><td>index in state vector of probability amplitudes </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>imaginary component at that index </dd></dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname">invalidQuESTInputError</td><td>if <code>qureg</code> is a density matrix, or if <code>index</code> is outside [0, <img class="formulaInl" alt="$2^{N}$" src="form_35.png"/>) where <img class="formulaInl" alt="$N = $" src="form_36.png"/> <code>qureg.numQubitsRepresented</code> </td></tr>
  </table>
  </dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Ania Brown </dd></dl>

<p class="definition">Definition at line <a class="el" href="QuEST_8c_source.html#l00685">685</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00685"></a><span class="lineno">  685</span>&#160;                                                   {</div>
<div class="line"><a name="l00686"></a><span class="lineno">  686</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a72feec2aaa05f98aed7f3c3fee141251">validateStateVecQureg</a>(qureg, __func__);</div>
<div class="line"><a name="l00687"></a><span class="lineno">  687</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a5f87419b253a97f6caadb72b507b9853">validateAmpIndex</a>(qureg, index, __func__);</div>
<div class="line"><a name="l00688"></a><span class="lineno">  688</span>&#160;    </div>
<div class="line"><a name="l00689"></a><span class="lineno">  689</span>&#160;    <span class="keywordflow">return</span> <a class="code" href="QuEST__internal_8h.html#abd509244d57657e148e4084c5ab5d28f">statevec_getImagAmp</a>(qureg, index);</div>
<div class="line"><a name="l00690"></a><span class="lineno">  690</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00208">statevec_getImagAmp()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00346">validateAmpIndex()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00479">validateStateVecQureg()</a>.</p>

<p class="reference">Referenced by <a class="el" href="test__calculations_8cpp_source.html#l01221">TEST_CASE()</a>.</p>

</div>
</div>
<a id="ga8cbe422d4981bf06847d229a4c6aa3df"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga8cbe422d4981bf06847d229a4c6aa3df">&#9670;&nbsp;</a></span>getNumAmps()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">long long int getNumAmps </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Get the number of probability amplitudes in a qureg object, given by 2^numQubits. </p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="QuEST_8c_source.html#l00672">672</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00672"></a><span class="lineno">  672</span>&#160;                                      {</div>
<div class="line"><a name="l00673"></a><span class="lineno">  673</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a72feec2aaa05f98aed7f3c3fee141251">validateStateVecQureg</a>(qureg, __func__);</div>
<div class="line"><a name="l00674"></a><span class="lineno">  674</span>&#160;    </div>
<div class="line"><a name="l00675"></a><span class="lineno">  675</span>&#160;    <span class="keywordflow">return</span> qureg.<a class="code" href="structQureg.html#adef4935cac95763c29164cf99b144ed4">numAmpsTotal</a>;</div>
<div class="line"><a name="l00676"></a><span class="lineno">  676</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00215">Qureg::numAmpsTotal</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00479">validateStateVecQureg()</a>.</p>

<p class="reference">Referenced by <a class="el" href="test__calculations_8cpp_source.html#l01259">TEST_CASE()</a>.</p>

</div>
</div>
<a id="ga73036c778d800703585ab3d8796a915f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga73036c778d800703585ab3d8796a915f">&#9670;&nbsp;</a></span>getNumQubits()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int getNumQubits </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Get the number of qubits in a qureg object. </p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="QuEST_8c_source.html#l00668">668</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00668"></a><span class="lineno">  668</span>&#160;                              {</div>
<div class="line"><a name="l00669"></a><span class="lineno">  669</span>&#160;    <span class="keywordflow">return</span> qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>;</div>
<div class="line"><a name="l00670"></a><span class="lineno">  670</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00208">Qureg::numQubitsRepresented</a>.</p>

<p class="reference">Referenced by <a class="el" href="test__calculations_8cpp_source.html#l01289">TEST_CASE()</a>.</p>

</div>
</div>
<a id="ga4a14d22379d399760b0cfc5c8053589b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga4a14d22379d399760b0cfc5c8053589b">&#9670;&nbsp;</a></span>getProbAmp()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> getProbAmp </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">long long int&#160;</td>
          <td class="paramname"><em>index</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Get the probability of a state-vector at an index in the full state vector. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">qureg</td><td>object representing a set of qubits </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">index</td><td>index in state vector of probability amplitudes </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>realEl*realEl + imagEl*imagEl </dd></dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname">invalidQuESTInputError</td><td>if <code>qureg</code> is a density matrix, or if <code>index</code> is outside [0, <img class="formulaInl" alt="$2^{N}$" src="form_35.png"/>) where <img class="formulaInl" alt="$N = $" src="form_36.png"/> <code>qureg.numQubitsRepresented</code> </td></tr>
  </table>
  </dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Ania Brown </dd></dl>

<p class="definition">Definition at line <a class="el" href="QuEST_8c_source.html#l00692">692</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00692"></a><span class="lineno">  692</span>&#160;                                                   {</div>
<div class="line"><a name="l00693"></a><span class="lineno">  693</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a72feec2aaa05f98aed7f3c3fee141251">validateStateVecQureg</a>(qureg, __func__);</div>
<div class="line"><a name="l00694"></a><span class="lineno">  694</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a5f87419b253a97f6caadb72b507b9853">validateAmpIndex</a>(qureg, index, __func__);</div>
<div class="line"><a name="l00695"></a><span class="lineno">  695</span>&#160;    </div>
<div class="line"><a name="l00696"></a><span class="lineno">  696</span>&#160;    <span class="keywordflow">return</span> <a class="code" href="QuEST__common_8c.html#a3afe58e49dce5536bc4c1b7caddf44a6">statevec_getProbAmp</a>(qureg, index);</div>
<div class="line"><a name="l00697"></a><span class="lineno">  697</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__common_8c_source.html#l00245">statevec_getProbAmp()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00346">validateAmpIndex()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00479">validateStateVecQureg()</a>.</p>

<p class="reference">Referenced by <a class="el" href="test__calculations_8cpp_source.html#l01322">TEST_CASE()</a>.</p>

</div>
</div>
<a id="ga1416145280c62c5dd5ec9bed89b4cd05"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga1416145280c62c5dd5ec9bed89b4cd05">&#9670;&nbsp;</a></span>getRealAmp()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> getRealAmp </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">long long int&#160;</td>
          <td class="paramname"><em>index</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Get the real component of the complex probability amplitude at an index in the state vector. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">qureg</td><td>object representing a set of qubits </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">index</td><td>index in state vector of probability amplitudes </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>real component at that index </dd></dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname">invalidQuESTInputError</td><td>if <code>qureg</code> is a density matrix, or if <code>index</code> is outside [0, <img class="formulaInl" alt="$2^{N}$" src="form_35.png"/>) where <img class="formulaInl" alt="$N = $" src="form_36.png"/> <code>qureg.numQubitsRepresented</code> </td></tr>
  </table>
  </dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Ania Brown </dd></dl>

<p class="definition">Definition at line <a class="el" href="QuEST_8c_source.html#l00678">678</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00678"></a><span class="lineno">  678</span>&#160;                                                   {</div>
<div class="line"><a name="l00679"></a><span class="lineno">  679</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a72feec2aaa05f98aed7f3c3fee141251">validateStateVecQureg</a>(qureg, __func__);</div>
<div class="line"><a name="l00680"></a><span class="lineno">  680</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a5f87419b253a97f6caadb72b507b9853">validateAmpIndex</a>(qureg, index, __func__);</div>
<div class="line"><a name="l00681"></a><span class="lineno">  681</span>&#160;    </div>
<div class="line"><a name="l00682"></a><span class="lineno">  682</span>&#160;    <span class="keywordflow">return</span> <a class="code" href="QuEST__internal_8h.html#abc9a9ef4344c7faaaf28ac25c76649b9">statevec_getRealAmp</a>(qureg, index);</div>
<div class="line"><a name="l00683"></a><span class="lineno">  683</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00198">statevec_getRealAmp()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00346">validateAmpIndex()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00479">validateStateVecQureg()</a>.</p>

<p class="reference">Referenced by <a class="el" href="test__calculations_8cpp_source.html#l01361">TEST_CASE()</a>.</p>

</div>
</div>
</div><!-- contents -->
<div class="ttc" id="aQuEST__validation_8c_html_af22919f5190ca1b3b6b52b8f2fb8213b"><div class="ttname"><a href="QuEST__validation_8c.html#af22919f5190ca1b3b6b52b8f2fb8213b">validateDensityMatrQureg</a></div><div class="ttdeci">void validateDensityMatrQureg(Qureg qureg, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00483">QuEST_validation.c:483</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_ac31c45c5a31c523be0eb26abba6cf598"><div class="ttname"><a href="QuEST__validation_8c.html#ac31c45c5a31c523be0eb26abba6cf598">validateTarget</a></div><div class="ttdeci">void validateTarget(Qureg qureg, int targetQubit, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00364">QuEST_validation.c:364</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_ad613c75ff252a88e54f911053bd2032c"><div class="ttname"><a href="QuEST__validation_8c.html#ad613c75ff252a88e54f911053bd2032c">validateOutcome</a></div><div class="ttdeci">void validateOutcome(int outcome, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00487">QuEST_validation.c:487</a></div></div>
<div class="ttc" id="aQuEST__internal_8h_html_a6ff3dc624b5fafe8edae4fe327c255a0"><div class="ttname"><a href="QuEST__internal_8h.html#a6ff3dc624b5fafe8edae4fe327c255a0">densmatr_calcInnerProduct</a></div><div class="ttdeci">qreal densmatr_calcInnerProduct(Qureg a, Qureg b)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l00441">QuEST_cpu_distributed.c:441</a></div></div>
<div class="ttc" id="aQuEST__common_8c_html_aef380928d1b0003411d6159ca6594cd5"><div class="ttname"><a href="QuEST__common_8c.html#aef380928d1b0003411d6159ca6594cd5">statevec_calcExpecPauliProd</a></div><div class="ttdeci">qreal statevec_calcExpecPauliProd(Qureg qureg, int *targetQubits, enum pauliOpType *pauliCodes, int numTargets, Qureg workspace)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__common_8c_source.html#l00465">QuEST_common.c:465</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_a72feec2aaa05f98aed7f3c3fee141251"><div class="ttname"><a href="QuEST__validation_8c.html#a72feec2aaa05f98aed7f3c3fee141251">validateStateVecQureg</a></div><div class="ttdeci">void validateStateVecQureg(Qureg qureg, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00479">QuEST_validation.c:479</a></div></div>
<div class="ttc" id="aQuEST__common_8c_html_ae0cfea24091c8336146aa84c2253992e"><div class="ttname"><a href="QuEST__common_8c.html#ae0cfea24091c8336146aa84c2253992e">statevec_calcExpecPauliSum</a></div><div class="ttdeci">qreal statevec_calcExpecPauliSum(Qureg qureg, enum pauliOpType *allCodes, qreal *termCoeffs, int numSumTerms, Qureg workspace)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__common_8c_source.html#l00480">QuEST_common.c:480</a></div></div>
<div class="ttc" id="aQuEST__internal_8h_html_ae45eefa65f4ecd37bab84fade7cf7f1f"><div class="ttname"><a href="QuEST__internal_8h.html#ae45eefa65f4ecd37bab84fade7cf7f1f">densmatr_calcPurity</a></div><div class="ttdeci">qreal densmatr_calcPurity(Qureg qureg)</div><div class="ttdoc">Computes the trace of the density matrix squared.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l01288">QuEST_cpu_distributed.c:1288</a></div></div>
<div class="ttc" id="aQuEST__internal_8h_html_a63cb88a5f4eb12fef087435b8db3f8eb"><div class="ttname"><a href="QuEST__internal_8h.html#a63cb88a5f4eb12fef087435b8db3f8eb">statevec_calcProbOfOutcome</a></div><div class="ttdeci">qreal statevec_calcProbOfOutcome(Qureg qureg, int measureQubit, int outcome)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l01260">QuEST_cpu_distributed.c:1260</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_a5be128290a7bba9a7f12d32cabe2276b"><div class="ttname"><a href="QuEST__validation_8c.html#a5be128290a7bba9a7f12d32cabe2276b">validateNumPauliSumTerms</a></div><div class="ttdeci">void validateNumPauliSumTerms(int numTerms, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00570">QuEST_validation.c:570</a></div></div>
<div class="ttc" id="aQuEST__common_8c_html_aeeec9fe1501e25930adf6c38763a158e"><div class="ttname"><a href="QuEST__common_8c.html#aeeec9fe1501e25930adf6c38763a158e">statevec_calcFidelity</a></div><div class="ttdeci">qreal statevec_calcFidelity(Qureg qureg, Qureg pureState)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__common_8c_source.html#l00377">QuEST_common.c:377</a></div></div>
<div class="ttc" id="aQuEST__common_8c_html_a3afe58e49dce5536bc4c1b7caddf44a6"><div class="ttname"><a href="QuEST__common_8c.html#a3afe58e49dce5536bc4c1b7caddf44a6">statevec_getProbAmp</a></div><div class="ttdeci">qreal statevec_getProbAmp(Qureg qureg, long long int index)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__common_8c_source.html#l00245">QuEST_common.c:245</a></div></div>
<div class="ttc" id="aQuEST__internal_8h_html_a6153547f245c05874161a105e9a2f02c"><div class="ttname"><a href="QuEST__internal_8h.html#a6153547f245c05874161a105e9a2f02c">densmatr_calcTotalProb</a></div><div class="ttdeci">qreal densmatr_calcTotalProb(Qureg qureg)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l00053">QuEST_cpu_distributed.c:53</a></div></div>
<div class="ttc" id="aQuEST__internal_8h_html_a0fb948ddab4ca210e523aa3c52639df4"><div class="ttname"><a href="QuEST__internal_8h.html#a0fb948ddab4ca210e523aa3c52639df4">statevec_calcExpecDiagonalOp</a></div><div class="ttdeci">Complex statevec_calcExpecDiagonalOp(Qureg qureg, DiagonalOp op)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l01523">QuEST_cpu_distributed.c:1523</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_a8a656a83bf0b44447188d06c2f8114cb"><div class="ttname"><a href="QuEST__validation_8c.html#a8a656a83bf0b44447188d06c2f8114cb">validateDiagonalOp</a></div><div class="ttdeci">void validateDiagonalOp(Qureg qureg, DiagonalOp op, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00677">QuEST_validation.c:677</a></div></div>
<div class="ttc" id="astructPauliHamil_html_ac1c6c9f6299cf83bbba88123216c3cac"><div class="ttname"><a href="structPauliHamil.html#ac1c6c9f6299cf83bbba88123216c3cac">PauliHamil::termCoeffs</a></div><div class="ttdeci">qreal * termCoeffs</div><div class="ttdoc">The coefficient of each Pauli product. This is a length numSumTerms array.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00164">QuEST.h:164</a></div></div>
<div class="ttc" id="astructPauliHamil_html_a4b8d38c403553c07ceddcd40c46ce6c8"><div class="ttname"><a href="structPauliHamil.html#a4b8d38c403553c07ceddcd40c46ce6c8">PauliHamil::pauliCodes</a></div><div class="ttdeci">enum pauliOpType * pauliCodes</div><div class="ttdoc">The Pauli operators acting on each qubit, flattened over every operator.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00162">QuEST.h:162</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_a6776217a5f7ba38b56175cf6db0f96e0"><div class="ttname"><a href="QuEST__validation_8c.html#a6776217a5f7ba38b56175cf6db0f96e0">validateMultiTargets</a></div><div class="ttdeci">void validateMultiTargets(Qureg qureg, int *targetQubits, int numTargetQubits, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00392">QuEST_validation.c:392</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_a87d22240ccfd81827a2a34b8d569d347"><div class="ttname"><a href="QuEST__validation_8c.html#a87d22240ccfd81827a2a34b8d569d347">validateMatchingQuregDims</a></div><div class="ttdeci">void validateMatchingQuregDims(Qureg qureg1, Qureg qureg2, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00495">QuEST_validation.c:495</a></div></div>
<div class="ttc" id="astructPauliHamil_html_a737e46b40ef8990cf004d22eb9dbe2e4"><div class="ttname"><a href="structPauliHamil.html#a737e46b40ef8990cf004d22eb9dbe2e4">PauliHamil::numSumTerms</a></div><div class="ttdeci">int numSumTerms</div><div class="ttdoc">The number of terms in the weighted sum, or the number of Pauli products.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00166">QuEST.h:166</a></div></div>
<div class="ttc" id="aQuEST__internal_8h_html_a70e3b0a2297c186d5c779af31459b4ca"><div class="ttname"><a href="QuEST__internal_8h.html#a70e3b0a2297c186d5c779af31459b4ca">densmatr_calcExpecDiagonalOp</a></div><div class="ttdeci">Complex densmatr_calcExpecDiagonalOp(Qureg qureg, DiagonalOp op)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l01541">QuEST_cpu_distributed.c:1541</a></div></div>
<div class="ttc" id="aQuEST__internal_8h_html_a7ebd3198a198f4cd20840f64fd8b84d0"><div class="ttname"><a href="QuEST__internal_8h.html#a7ebd3198a198f4cd20840f64fd8b84d0">statevec_calcInnerProduct</a></div><div class="ttdeci">Complex statevec_calcInnerProduct(Qureg bra, Qureg ket)</div><div class="ttdoc">Terrible code which unnecessarily individually computes and sums the real and imaginary components of...</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l00035">QuEST_cpu_distributed.c:35</a></div></div>
<div class="ttc" id="aQuEST__internal_8h_html_abd509244d57657e148e4084c5ab5d28f"><div class="ttname"><a href="QuEST__internal_8h.html#abd509244d57657e148e4084c5ab5d28f">statevec_getImagAmp</a></div><div class="ttdeci">qreal statevec_getImagAmp(Qureg qureg, long long int index)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l00208">QuEST_cpu_distributed.c:208</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_a066b0c4d0b02a0f3b9be7e5c68d9de6a"><div class="ttname"><a href="QuEST__validation_8c.html#a066b0c4d0b02a0f3b9be7e5c68d9de6a">validatePauliHamil</a></div><div class="ttdeci">void validatePauliHamil(PauliHamil hamil, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00619">QuEST_validation.c:619</a></div></div>
<div class="ttc" id="aQuEST__internal_8h_html_aa6c3f86010ad398f42b0577ea3bb5bcf"><div class="ttname"><a href="QuEST__internal_8h.html#aa6c3f86010ad398f42b0577ea3bb5bcf">densmatr_calcFidelity</a></div><div class="ttdeci">qreal densmatr_calcFidelity(Qureg qureg, Qureg pureState)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l00415">QuEST_cpu_distributed.c:415</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_a2b88b068a8242ee28da42c7324cdd078"><div class="ttname"><a href="QuEST__validation_8c.html#a2b88b068a8242ee28da42c7324cdd078">validateMatchingQuregPauliHamilDims</a></div><div class="ttdeci">void validateMatchingQuregPauliHamilDims(Qureg qureg, PauliHamil hamil, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00624">QuEST_validation.c:624</a></div></div>
<div class="ttc" id="astructQureg_html_acf78445e9435d09f44f0cc832c6aee79"><div class="ttname"><a href="structQureg.html#acf78445e9435d09f44f0cc832c6aee79">Qureg::isDensityMatrix</a></div><div class="ttdeci">int isDensityMatrix</div><div class="ttdoc">Whether this instance is a density-state representation.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00206">QuEST.h:206</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_a031812e1cf2c98d72d795cea7bbe73a5"><div class="ttname"><a href="QuEST__validation_8c.html#a031812e1cf2c98d72d795cea7bbe73a5">validateMatchingQuregTypes</a></div><div class="ttdeci">void validateMatchingQuregTypes(Qureg qureg1, Qureg qureg2, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00499">QuEST_validation.c:499</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_a5f87419b253a97f6caadb72b507b9853"><div class="ttname"><a href="QuEST__validation_8c.html#a5f87419b253a97f6caadb72b507b9853">validateAmpIndex</a></div><div class="ttdeci">void validateAmpIndex(Qureg qureg, long long int ampInd, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00346">QuEST_validation.c:346</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_a7adc86571f1154558676d95daf0cbd1f"><div class="ttname"><a href="QuEST__validation_8c.html#a7adc86571f1154558676d95daf0cbd1f">validateSecondQuregStateVec</a></div><div class="ttdeci">void validateSecondQuregStateVec(Qureg qureg2, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00503">QuEST_validation.c:503</a></div></div>
<div class="ttc" id="astructQureg_html_ad08dff5316b8937f4b2a1417591543dc"><div class="ttname"><a href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">Qureg::numQubitsRepresented</a></div><div class="ttdeci">int numQubitsRepresented</div><div class="ttdoc">The number of qubits represented in either the state-vector or density matrix.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00208">QuEST.h:208</a></div></div>
<div class="ttc" id="astructQureg_html_adef4935cac95763c29164cf99b144ed4"><div class="ttname"><a href="structQureg.html#adef4935cac95763c29164cf99b144ed4">Qureg::numAmpsTotal</a></div><div class="ttdeci">long long int numAmpsTotal</div><div class="ttdoc">Total number of amplitudes, which are possibly distributed among machines.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00215">QuEST.h:215</a></div></div>
<div class="ttc" id="astructComplex_html_ab5b2e2eca02131fc74b289a83636cbe3"><div class="ttname"><a href="structComplex.html#ab5b2e2eca02131fc74b289a83636cbe3">Complex::real</a></div><div class="ttdeci">qreal real</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00105">QuEST.h:105</a></div></div>
<div class="ttc" id="astructComplex_html_a84f5439aad0ef495efdd3b4c1c02d27e"><div class="ttname"><a href="structComplex.html#a84f5439aad0ef495efdd3b4c1c02d27e">Complex::imag</a></div><div class="ttdeci">qreal imag</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00106">QuEST.h:106</a></div></div>
<div class="ttc" id="aQuEST__internal_8h_html_a8c9da88f734b0862f4cce7d819e6d3b5"><div class="ttname"><a href="QuEST__internal_8h.html#a8c9da88f734b0862f4cce7d819e6d3b5">densmatr_calcHilbertSchmidtDistance</a></div><div class="ttdeci">qreal densmatr_calcHilbertSchmidtDistance(Qureg a, Qureg b)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l00430">QuEST_cpu_distributed.c:430</a></div></div>
<div class="ttc" id="astructComplex_html"><div class="ttname"><a href="structComplex.html">Complex</a></div><div class="ttdoc">Represents one complex number.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00103">QuEST.h:103</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_aa194ba5f5c6e19c6caa4c715b3dbefcc"><div class="ttname"><a href="QuEST__validation_8c.html#aa194ba5f5c6e19c6caa4c715b3dbefcc">validatePauliCodes</a></div><div class="ttdeci">void validatePauliCodes(enum pauliOpType *pauliCodes, int numPauliCodes, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00563">QuEST_validation.c:563</a></div></div>
<div class="ttc" id="aQuEST__internal_8h_html_ae37b3eff5d3affbc1edfe216cabc1c53"><div class="ttname"><a href="QuEST__internal_8h.html#ae37b3eff5d3affbc1edfe216cabc1c53">densmatr_calcProbOfOutcome</a></div><div class="ttdeci">qreal densmatr_calcProbOfOutcome(Qureg qureg, int measureQubit, int outcome)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l01276">QuEST_cpu_distributed.c:1276</a></div></div>
<div class="ttc" id="aQuEST__internal_8h_html_abc9a9ef4344c7faaaf28ac25c76649b9"><div class="ttname"><a href="QuEST__internal_8h.html#abc9a9ef4344c7faaaf28ac25c76649b9">statevec_getRealAmp</a></div><div class="ttdeci">qreal statevec_getRealAmp(Qureg qureg, long long int index)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l00198">QuEST_cpu_distributed.c:198</a></div></div>
<div class="ttc" id="aQuEST__internal_8h_html_ad65ad1b5ea6f30b0c6b4ffda96e1a8e6"><div class="ttname"><a href="QuEST__internal_8h.html#ad65ad1b5ea6f30b0c6b4ffda96e1a8e6">statevec_calcTotalProb</a></div><div class="ttdeci">qreal statevec_calcTotalProb(Qureg qureg)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l00088">QuEST_cpu_distributed.c:88</a></div></div>
<!-- HTML footer for doxygen 1.8.8-->
<!-- start footer part -->
</div>
</div>
</div>
</div>
</div>
</body>
        <script type="text/javascript" src="boot.js"></script>
</html>
